<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <base th:href="${#servletContext.getContextPath()+'/'}">
    <link rel="stylesheet" type="text/css" href="bootstrap-3.4.1/dist/css/bootstrap.css">
    <script type="text/javascript" src="jquery/jquery-3.6.1.min.js"></script>
    <script type="text/javascript" src="jquery/http.js"></script>

    <script type="text/javascript">
        $(function () {

            //1.先获取值
            var sex = [[${systemUser.sex}]];
            console.log(sex);
            //2.找到他
            $("[name='sex']").each(function (index,item) {
                    if($(item).val() == sex){
                        $(item).attr("checked",true);
                        return;
                    }
            });
            $("#form-user-update").submit(function () {
                submit("form-user-update", "UserServlet/update", function (data) {
                    // 这个函数服务端响应成功后调用
                    location.href = "UserServlet/list"
                });
                return false;
            });
        })




    </script>

</head>
<body>
<form class="form-horizontal" id="form-user-update">
    <div class="form-group">
        <label class="col-sm-2 control-label">username</label>
        <div class="col-sm-2">
            <input type="hidden" name="id" th:value="${systemUser.id}">
            <input type="text" class="form-control" name="username" th:value="${systemUser.username}" placeholder="请输入用户名">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">email</label>
        <div class="col-sm-2">
            <input type="email" class="form-control" name="email" th:value="${systemUser.email}" placeholder="email...">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">birthday</label>
        <div class="col-sm-2">
            <input type="date" class="form-control" name="birthday" th:value="${systemUser.birthday}" placeholder="birthday...">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">sex</label>
        <div class="radio">
            <label class="radio-inline">
                <input type="radio" name="sex" value="1" >男
            </label>
            <label class="radio-inline">
                <input type="radio" name="sex" value="0" >女
            </label>
        </div>

    </div>

    <div class="form-group">
        <div class="col-sm-offset-2 col-sm-10">
            <button type="submit" class="btn btn-default">添加</button>
        </div>
    </div>
</form>
</body>
</html>